﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.XtraEditors;
using DevExpress.XtraReports;
using COMOSOFT.Class;
using DevExpress.XtraReports.UI;
using DevExpress.LookAndFeel;

namespace COMOSOFT.JobManagement.Froms
{
    public partial class FrmSetupReport : Form
    {
        ClassShare cls = new Class.ClassShare("FrmSetupReport");
        DateTime fromdate,todate;
        string Status=null,Type=null;
        public FrmSetupReport()
        {
            InitializeComponent();
        }

        private void bnt_Ok_Click(object sender, EventArgs e)
        {
            try
            {
                int numitem = checkedListBox_Status.CheckedItems.Count;
                if (numitem > 0)
                {
                    Status = checkedListBox_Status.CheckedItems[0].ToString();
                    for (int item = 1; item < numitem; item++)
                    {
                        Status += "," + checkedListBox_Status.CheckedItems[item].ToString();
                    }
                }               


                numitem = checkedListBox_Type.CheckedItems.Count;
                if (numitem > 0)
                {
                    Type = checkedListBox_Type.CheckedItems[0].ToString();
                    for (int item = 1; item < numitem; item++)
                    {
                        Type += "," + checkedListBox_Type.CheckedItems[item].ToString();
                    }

                    fromdate = Convert.ToDateTime(dateEdit_FromDate.EditValue);
                    todate = Convert.ToDateTime(dateEdit_ToDate.EditValue);

                    JobReport jobrpt = new JobReport(fromdate, todate, Status, ClassShare.Usid, Type);
                    ReportPrintTool printTool = new ReportPrintTool(jobrpt);
                    printTool.ShowRibbonPreview(UserLookAndFeel.Default);
                }                
            }
            catch
            {
                MessageBox.Show("Not thing report");
            }
        }

        private void FrmSetupReport_Load(object sender, EventArgs e)
        {
            dateEdit_FromDate.EditValue = DateTime.Now;
            dateEdit_ToDate.EditValue = DateTime.Now;           
        }

        private void bnt_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
